package com.itheima.test;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Chenke Zhao
 * @date 2025/5/23 10:38
 * @description POIDemo1
 */
public class POIDemo1 {

    //创建一个旧版本的excel文件

    public static void main(String[] args) throws IOException {
        //        创建工作簿
        Workbook workbook = new HSSFWorkbook();
        //        创建工作表
        Sheet sheet = workbook.createSheet("POI测试低版本excel");
        //        创建行
        Row row = sheet.createRow(0);
        //        创建单元格
        Cell cell = row.createCell(0);
        //        写入数据
        cell.setCellValue("hello");

        workbook.write(new FileOutputStream("d:\\poi1.xls"));
        workbook.close();
    }
}
